package com.gdface.admin.gdface_attend.utils;


import net.gdface.attend.AttendLogBean;
import net.gdface.attend.AttendLogManager;
import net.gdface.attend.AttendUserBean;
import net.gdface.attend.AttendUserManager;
import net.gdface.attend.exception.DAOException;

/**
 * Created by admin on 2017/12/28.
 *
 * 服务器数据库操作
 *
 */

public class MySQLUtils {

    public static String def = "000";

    /**
     * 插入用户数据
     *
     * @param bean
     */
    public static void insertUser(AttendUserBean bean) throws DAOException {
        AttendUserManager.getInstance().insert(bean);
    }

    /**
     * 删除指定id用户数据
     *
     * @param id
     */
    public static void deleteUser(int id) throws DAOException {
        AttendUserManager.getInstance().deleteByPrimaryKey(id);
    }

    /**
     * 更新用户数据
     *
     * @param bean
     */
    public static void updateUser(AttendUserBean bean) throws DAOException {
        AttendUserManager.getInstance().update(bean);
    }

    /**
     * 下载所有用户数据
     *
     * @return
     */
    public static AttendUserBean[] findUser() throws DAOException {
        return AttendUserManager.getInstance().loadAll();
    }

    /**
     * 插入Log数据
     * @param bean
     * @throws DAOException
     */
    public static void insertLog(AttendLogBean bean) throws DAOException {
        AttendLogManager.getInstance().insert(bean);
    }

    /**
     * 删除log数据
     * @param id
     * @throws DAOException
     */
    public void deleteLog(int id) throws DAOException {
        AttendLogManager.getInstance().deleteByPrimaryKey(id);
    }

    /**
     * 更新log数据
     * @param bean
     * @throws DAOException
     */
    public void updateLog(AttendLogBean bean) throws DAOException {
        AttendLogManager.getInstance().update(bean);
    }

    /**
     * 下载所有log数据
     * @return
     * @throws DAOException
     */
    private static AttendLogBean[] findLog() throws DAOException {
        return AttendLogManager.getInstance().loadAll();
    }


}
